//package com.android.cl.coludtf.network;
//
//
//import android.util.Log;
//
//import com.android.cl.coludtf.utils.log.MyLog;
//
//import java.io.IOException;
//import java.util.Map;
//
//import okhttp3.Call;
//import okhttp3.Callback;
//import okhttp3.FormBody;
//import okhttp3.MediaType;
//import okhttp3.OkHttpClient;
//import okhttp3.Request;
//import okhttp3.RequestBody;
//import okhttp3.Response;
//
//public class okHttpHelper {
//    private static final String TAG = "okhttp";
//    private static String HttpUrl;
//    public static final MediaType JSON = MediaType.get("application/json; charset=utf-8");
//
//    /**
//     * @Description OkHttp异步get请求
//     * @Author lei-chen
//     * @Time 2020/04/30 9:00
//     */
//    public static void getRequestAsyn(String url, final ResultCallback callback) {
//        OkHttpClient client = new OkHttpClient();
//        Log.d(TAG, HttpUrl + url);
//        final Request request = new Request
//                .Builder()
//                .url(HttpUrl + url)
//                .build();
//        Call call = client.newCall(request);
//        call.enqueue(new Callback() {
//            @Override
//            public void onFailure(Call call, IOException e) {
//                MyLog.d(TAG, "OkHttp Asyn Get Call Failure");
//                callback.onFailure(String.valueOf(e));
//            }
//
//            @Override
//            public void onResponse(Call call, Response response) throws IOException {
//                if (response.isSuccessful()) {
//                    MyLog.d(TAG, "Asyn Get Response is Success");
//                    String result = response.body().string();
//                    callback.onResponse(result);
//                } else {
//                    MyLog.d(TAG, "Asyn Get Response is Failure");
//                }
//
//            }
//        });
//    }
//
//    /**
//     * @Description OkHttp异步get请求
//     * @Author lei-chen
//     * @Time 2020/04/30 9:00
//     */
//    public void postRequestAsyn(final String url, Map<String, String> params, final ResultCallback callback) {
//        OkHttpClient client = new OkHttpClient();
//        FormBody.Builder builder = new FormBody.Builder();
//        for (Map.Entry<String, String> entry : params.entrySet()) {
//            builder.add(entry.getKey(), entry.getValue());
//        }
//        RequestBody body = builder.build();
//        Request request = new Request.Builder()
//                .post(body)
//                .url(url)
//                .build();
//        Call call = client.newCall(request);
//        call.enqueue(new Callback() {
//            @Override
//            public void onFailure(Call call, IOException e) {
//                MyLog.d(TAG, "OkHttp Asyn Post Call Failure");
//                callback.onFailure(String.valueOf(e));
//            }
//
//            @Override
//            public void onResponse(Call call, Response response) throws IOException {
//                if (response.isSuccessful()) {
//                    MyLog.d(TAG, "Asyn Post Response is Success");
//                    String result = response.body().string();
//                    callback.onResponse(result);
//                } else {
//                    MyLog.d(TAG, "Asyn Post Response is Failure");
//                }
//
//
//            }
//        });
//    }
//}
